package Java并发实现原理;

import java.util.concurrent.RecursiveAction;

public class SortTask extends RecursiveAction {

    final long[] array;
    final int lo;
    final int hi;

    public SortTask(long[] array) {
        this.array = array;
        this.lo = 0;
        this.hi = array.length - 1;
    }

    public SortTask(long[] array, int lo, int hi) {
        this.array = array;
        this.lo = lo;
        this.hi = hi;
    }

    @Override
    protected void compute() {
        if (lo < hi) {
            int pivot = partition(array, lo, hi);
            SortTask left = new SortTask(array, lo, pivot - 1);
            SortTask right = new SortTask(array, pivot + 1, hi);
            left.fork();
            right.fork();
            left.join();
            right.join();
        }
    }

    private int partition(long[] array, int lo, int hi) {
        long x = array[hi];
        int i = lo - 1;
        return 0;
    }
}
